package com.chj.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serializable;
@Slf4j
public class IdGenerator implements IdentifierGenerator {

	private final IdWorker idWorker = new IdWorker();

	@Override
	public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
		return new Long(this.idWorker.nextId());
	}
}
